﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Automobile.service.BLL;
namespace Automobile.service.UI
{
    public partial class SupplierShow : System.Web.UI.Page
    {
        SupplierBLL bll = new SupplierBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                Load();
                Session["count"] = bll.count();
            }
           
        }
        public void Load()
        {
            this.Repeater1.DataSource = bll.ShowSupplier();//获取数据源
            this.Repeater1.DataBind();//绑定数据源
            int count = bll.CountSupplier();
        }

        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string eName = e.CommandName;//获取当前要执行的命令名称
            string stuID = e.CommandArgument.ToString();//获取当前绑定的主键值
            switch(eName)
            {
                case "Del":
                    if (bll.Del(Convert.ToInt32(stuID))>0)
                    {
                        Response.Write("<script>alert('删除成功！');</script>");
                        Load();
                    }
                    else
                    {
                        Response.Write("<script>alert('删除失败！');</script>");
                    }
                     break ;
                case "Upt":
                     Response.Redirect("SupplierEdit.aspx?id=" + stuID);
                        break;
            }
        }

        protected void Unnamed_ServerClick(object sender, EventArgs e)
        {
            string Supplier_Name = this.Supplier_Name.Value;
            this.Repeater1.DataSource = bll.ShowSupplier_Sel(Supplier_Name);//获取数据源
            this.Repeater1.DataBind();//绑定数据源
        }
       
    }
}